import type { ConsultEnum } from '@/enums'
import type { IllnessForm, PartialConsult } from '@/types/consult'
import {defineStore} from 'pinia'
import { ref } from 'vue'

export const useConsultStore = defineStore('cp-consult',()=>{
  //定义问诊-保存/修改问诊订单响应式数据
  const consult = ref<PartialConsult>({})
   // 保存就诊类型
  const setType =(type:ConsultEnum)=>{
        consult.value.type=type
  }
  //保存极速问诊类型
  const setIllnessType = (type:0|1)=>{
     consult.value.illnessType = type
  }
  //保存选择的科室id
const setDepIdType =(id:string)=>{
  consult.value.depId =id
}
//保存图文患者表单信息
const setIllness =(illness:IllnessForm)=>{
    consult.value.illnessDesc =illness.illnessDesc
    consult.value.illnessTime =illness.illnessTime
    consult.value.consultFlag =illness.consultFlag
    consult.value.pictures =illness.pictures
}
//记录患者ID
const setPatient = (id:string)=>{
  consult.value.patientId = id
}
//记录优惠券id
const setCouponId =(id:string)=>{
  consult.value.couponId =id
}

//清除清空本地存储的问诊订单信息
const clear = ()=>{
  consult.value = {}
}
return {
    consult,
    setType,
    setIllnessType,
    setDepIdType,
    setIllness,
    setPatient,
    setCouponId,
    clear
  }
},{
  persist: true
}
)